package cn.zhz.service.user.impl;

import cn.zhz.dao.UserDao;
import cn.zhz.entity.User;
import cn.zhz.service.user.UserService;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service("userService")
@Qualifier("userDao")
public class UserServiceImpl implements UserService {
    @Autowired
    @Resource
    //声明接口类型的引用和具体实现类解耦合
    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }


    @Override
    public void addNewUser(User user) {
        //调用UserDao的方法保存用户信息
        System.out.println(user.getId());
        System.out.println(user.getUserName());
        System.out.println(user.getUserPassword());
        System.out.println(user.getEmail());
        userDao.save(user);
    }

}
